var appid = '';
var token = '';
$(document).ready(function() {
	//获取token，调用API服务
	auth();
});

function auth() {
	$.ajax({
		type: 'get',
		//async:false,
		url: "http://v2.mashupcloud.cn/developer/auth.do",
		data: {
			appkey: 'IwgITBdJsnUgJQwKWfjGxrDjmRDqnURh',
			appsecret: 'tnDXgDWoFOwvysUSdiMQAieAQfLCXxTn'

		},
		//dataType: "json",
		success: function(json) {

			var jo = eval(json);

			var token = jo[1];

			var appid = jo[2];
			sessionStorage.setItem("token", token);
			sessionStorage.setItem("appid", appid);
		},

		error: function(json) {
			console.log("err:" + json);
		}

	});

}
var vue = new Vue({
	el: "body",
	data: {
		phone: "",
		pwd: "",
		show: []
	},
	methods: {
		load: function() {
			var token = sessionStorage.getItem("token");
			var appid = sessionStorage.getItem("appid");
			$.ajax({
				type: 'get',
				url: "http://v2.mashupcloud.cn/SQL/load/",
				data: {
					appid: appid,
					token: token,
					name: 'load',
					_v1: vue.phone, //参数1  _v3,_v4 .......
					_v2: vue.pwd //参数1  _v3,_v4 .......
				},
				success: function(json) {
					console.log("json==" + json);
					this.show = JSON.parse(json);
					if(this.show[2].length > 0) {
						sessionStorage.setItem("username", vue.phone);
						location.href = "../description/description.html";
					}else{
						alert("帐号或密码错误")
					}
				},
				error: function(json) {
					console.log("err:" + json);
				}
			});
		}
	}
})